﻿Public Class AnularTransaccion
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnbuscar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnbuscar.Click
        Dim objPago As New PagoBL
        If txtdni.Text = "" Then
            ScriptManager.RegisterClientScriptBlock(Me, GetType(String), "mensaje", "alert('Ingrese un Dni válido')", True)
            Exit Sub
        Else
            CargarTransacciones()
        End If
    End Sub
#Region "Custom Methods"
    Private Sub CargarTransacciones()
        Dim obj As New TransaccionBL()
        Dim dt As New DataTable()
        dt = obj.ListaTransaccionesxdni(txtdni.Text)
        If dt.Rows.Count > 0 Then
            gvtransacciones.DataSource = dt
            gvtransacciones.DataBind()
        Else
            ScriptManager.RegisterClientScriptBlock(Me, GetType(String), "mensaje", "alert('El cliente no existe')", True)
            gvtransacciones.DataSource = Nothing
            gvtransacciones.DataBind()
        End If
        
    End Sub

#End Region

    Protected Sub gvtransacciones_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gvtransacciones.RowDeleting
        Dim indice As Integer = e.RowIndex
        Dim idtran As Integer = gvtransacciones.Rows(indice).Cells(0).Text
        Dim objtransaccion As New TransaccionDAL()
        objtransaccion.EliminarTransaccion(idtran)

        CargarTransacciones()

    End Sub
End Class